<!--
 * @Author: your name
 * @Date: 2021-11-13 14:49:06
 * @LastEditTime: 2021-11-13 15:33:19
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /vue-form-json/src/components/form/formItem.vue
-->
<template>
  <div>
    <label v-if="label">{{ label }}</label>
    <slot></slot>
  </div>
</template>
<script>
import Emitter from '@/mixins/emitter.js';
export default {
  name: 'iFormItem',
  mixins: [ Emitter ],
  props: {
    label: { type: String, default: '' },
    prop: { type: String }
  },
  mounted() {
    if (this.prop) {
      this.dispatch('iForm', 'form-add', this);
    }
  },
  // 组件销毁前，将实例从 Form 的缓存中移除
  beforeDestroy () {
    this.dispatch('iForm', 'form-remove', this);
  },
}
</script>